package com.hua.state;

import org.omg.PortableServer.THREAD_POLICY_ID;

public class TestDaemon {
    public static void main(String[] args) {


        God god = new God();
        You you = new You();

        Thread thread = new Thread(god);
        thread.setDaemon(true);//默认是false
        thread.start();//上帝守护线程启动

//        new Thread(god).setDaemon(true);



        new Thread(you).start();


    }
}

//上帝
class God implements Runnable{
    @Override
    public void run() {
        while (true){
            System.out.println("上帝保佑你");

        }
//        System.out.println();
    }
}

//你
class You implements Runnable{
    @Override
    public void run() {
        for (int i = 0; i < 365000; i++) {
            System.out.println("happy");
        }
        System.out.println("======godbye world==================");
    }
}